<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.util.container.more.CacheMap</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.util.container.more.CacheMap");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791">tango.util.container.more.CacheMap</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Initial release: April 2008<br><br>
<b>author:</b><br>Kris<br><br>
<b>Since:</b><br>0.99.7<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L42">CacheMap</a></span>
<script>explorer.outline.addDecl('CacheMap');</script>(K, V, alias Hash = Container.hash, 
                      alias Reap = Container.reap, 
                      alias Heap = Container.Collect);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">CacheMap extends the basic hashmap type by adding a limit to 
        the number of items contained at any given time. In addition, 
        CacheMap sorts the cache entries such that those entries 
        frequently accessed are at the head of the queue, and those
        least frequently accessed are at the tail. When the queue 
        becomes full, old entries are dropped from the tail and are 
        reused to house new cache entries. </font><br><br>
<font color="black">In other words, it retains MRU items while dropping LRU when
        capacity is reached.<br><br>        This is great for keeping commonly accessed items around, while
        limiting the amount of memory used. Typically, the queue size 
        would be set in the thousands<br><br></font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L67">this</a></span>
<script>explorer.outline.addDecl('this');</script>(uint <span class="funcparam">capacity</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Construct a cache with the specified maximum number of 
                entries. Additions to the cache beyond this number will
                reuse the slot of the least-recently-referenced cache
                entry. </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>~<span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L91">this</a></span>
<script>explorer.outline.addDecl('this');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">clean up when done
                
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L102">reaper</a></span>
<script>explorer.outline.addDecl('reaper');</script>(K, R)(K <span class="funcparam">k</span>, R <span class="funcparam">r</span>); [static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Reaping callback for the hashmap, acting as a trampoline</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>uint <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L112">size</a></span>
<script>explorer.outline.addDecl('size');</script>(); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>int <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L123">opApply</a></span>
<script>explorer.outline.addDecl('opApply');</script>(int delegate(ref K key, ref V value) <span class="funcparam">dg</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Iterate from MRU to LRU entries</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L148">get</a></span>
<script>explorer.outline.addDecl('get');</script>(K <span class="funcparam">key</span>, ref V <span class="funcparam">value</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Get the cache entry identified by the given key</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L174">add</a></span>
<script>explorer.outline.addDecl('add');</script>(K <span class="funcparam">key</span>, V <span class="funcparam">value</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Place an entry into the cache and associate it with the
                provided key. Note that there can be only one entry for
                any particular key. If two entries are added with the 
                same key, the second effectively overwrites the first.</font><br><br>
<font color="black">Returns true if we added a new entry; false if we just
                replaced an existing one<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L198">take</a></span>
<script>explorer.outline.addDecl('take');</script>(K <span class="funcparam">key</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove the cache entry associated with the provided key. 
                Returns false if there is no such entry.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L212">take</a></span>
<script>explorer.outline.addDecl('take');</script>(K <span class="funcparam">key</span>, ref V <span class="funcparam">value</span>); [final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove &#40;and return&#41; the cache entry associated with the 
                provided key. Returns false if there is no such entry.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L237">deReference</a></span>
<script>explorer.outline.addDecl('deReference');</script>(Ref <span class="funcparam">entry</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Place a cache entry at the tail of the queue. This makes
                it the least-recently referenced.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L259">reReference</a></span>
<script>explorer.outline.addDecl('reReference');</script>(Ref <span class="funcparam">entry</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Move a cache entry to the head of the queue. This makes
                it the most-recently referenced.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L282">addEntry</a></span>
<script>explorer.outline.addDecl('addEntry');</script>(K <span class="funcparam">key</span>, V <span class="funcparam">value</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add an entry into the queue. If the queue is full, the
                least-recently-referenced entry is reused for the new
                addition. </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L309">QueuedEntry</a></span>
<script>explorer.outline.addDecl('QueuedEntry');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">A doubly-linked list entry, used as a wrapper for queued 
                cache entries. Note that this class itself is a valid cache 
                entry.
        
</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L322">set</a></span>
<script>explorer.outline.addDecl('set');</script>(K <span class="funcparam">key</span>, V <span class="funcparam">value</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set this linked-list entry with the given arguments. </font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L336">prepend</a></span>
<script>explorer.outline.addDecl('prepend');</script>(Ref <span class="funcparam">before</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Insert this entry into the linked-list just in 
                        front of the given entry.
        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L360">append</a></span>
<script>explorer.outline.addDecl('append');</script>(Ref <span class="funcparam">after</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add this entry into the linked-list just after 
                        the given entry.
        
</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Ref <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/util/container/more/CacheMap.d?rev=3791#L385">extract</a></span>
<script>explorer.outline.addDecl('extract');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove this entry from the linked-list. The 
                        previous and next entries are patched together 
                        appropriately.
        
</font><br><br></dd></dl></dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2008 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sat Aug  2 16:08:33 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>